package cn.edu.bjut.homework.chapter3;

class Ipc {
    private String section;
    private int class_num;
    private String subclass;
    private int main_group;
    private int sub_group;

    public Ipc(String section, int class_num, String subclass, int main_group, int sub_group) {
        this.section = section;
        this.class_num = class_num;
        this.subclass = subclass;
        this.main_group = main_group;
        this.sub_group = sub_group;
    }

    public Ipc(String s) {
        this.section = s.substring(0, 1);
        this.class_num = Integer.parseInt(s.substring(1, 3));
        this.subclass = s.substring(3, 4);
        this.main_group = Integer.parseInt(s.substring(4, 7).trim());
        this.sub_group = Integer.parseInt(s.substring(8).trim());
    }

    public String getSection() {
        return section;
    }

    public int getClass_num() {
        return class_num;
    }

    public String getSubclass() {
        return subclass;
    }

    public int getMain_group() {
        return main_group;
    }

    public int getSub_group() {
        return sub_group;
    }

    public void setSection(String section) {
        this.section = section;
    }

    public void setClass_num(int class_num) {
        this.class_num = class_num;
    }

    public void setSubclass(String subclass) {
        this.subclass = subclass;
    }

    public void setMain_group(int main_group) {
        this.main_group = main_group;
    }

    public void setSub_group(int sub_group) {
        this.sub_group = sub_group;
    }

    @Override
    public String toString() {
        return String.format("%s%02d%s%4d/%-5d", section, class_num, subclass, main_group, sub_group);
    }
}
